package com.zy.list

import android.content.pm.ActivityInfo
import android.os.Bundle
import androidx.fragment.app.Fragment
import com.zy.activity.BaseMainActivity
import com.zy.list.ListConstant.MODE_TYPE_EDIT
import com.zy.list.ListConstant.MODE_TYPE_SHOW
import com.zy.list.layout.DiyLayoutEditFragment
import com.zy.list.layout.DiyLayoutShowFragment
import com.zy.zlog.ZLog

open class DIYLayoutMainActivity : BaseMainActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        //设置横屏
        requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
    }

    override val containerFragment: Fragment?
        get() {
            val fileID = intent.getLongExtra(ListConstant.ARG_FILE_ID, 0L)
            val mode = intent.getIntExtra(ListConstant.ARG_OPEN_FILE_MODE, MODE_TYPE_SHOW)
            ZLog.d("ZY-DIYLayoutMainActivity", "fileID= $fileID mode=$mode")
            return when (mode) {
                MODE_TYPE_EDIT -> DiyLayoutEditFragment.newInstance(fileID)
                else -> {
                    DiyLayoutShowFragment.newInstance(fileID)
                }
            }
        }
}